//
//  ControlView.swift
//  swiftStudy
//
//  Created by Zhang on 2021/3/15.
//

import SwiftUI

struct ControlView: View {
    
    private let itemInfo : HomeListItem
    
    init(itemInfo:HomeListItem) {
        self.itemInfo = itemInfo
    }
    
    var body: some View {
        
        switch itemInfo.title {
        //忽略掉顶部的安全区域,并隐藏默认的导航栏
        //VariableView().navigationBarHidden(true).edgesIgnoringSafeArea(.top)
        case "变量与常量":
            //加载对应的页面,并设置标题
            VariableView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "基本数据类型":
            DataTypeView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "字符、字符串":
            CollectionView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "集合":
            CollectionView2().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "运算符":
            OperatorView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "函数基础":
            FunctionView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "函数类型与嵌套":
            FunctionView2().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "枚举":
            EnumView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "类与结构体":
            ClassView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "属性":
            PropertyView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "方法":
            MethodView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "构造方法和析构方法":
            ConstructorView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "内存管理与异常处理":
            MemoryManagementView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "类型转换、泛型、扩展与协议":
            ExtendView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "文字":
            TextView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "按钮":
            ButtonView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        case "MapKit":
            MapView().navigationBarHidden(true).edgesIgnoringSafeArea(.all)
        case "List":
            ListView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        default:
            ReferenceView().navigationBarTitle(itemInfo.title,displayMode: .inline)
        }
    }
}

